<template>
  <div class="error-page">
    <!-- 背景装饰 -->
    <div class="bg-pattern"></div>
    
    <!-- 404主体内容 -->
    <div class="error-container">
      <!-- 错误图标 -->
      <div class="error-icon">
        <el-icon :size="120">
          <WarningFilled />
        </el-icon>
      </div>
      
      <!-- 错误信息 -->
      <div class="error-info">
        <h1 class="error-code">404</h1>
        <p class="error-message">抱歉，您访问的页面不存在或已被移除</p>
        <p class="error-description">可能是输入的地址有误，或该页面已被删除</p>
      </div>
      
      <!-- 操作按钮 -->
      <div class="error-actions">
        <el-button 
          type="primary" 
          size="large" 
          @click="handleBackHome"
          class="back-home-btn"
        >
          <HomeFilled class="mr-2" />
          返回首页
        </el-button>
        <el-button 
          size="large" 
          @click="handleGoBack"
          class="go-back-btn"
        >
          <ArrowLeft class="mr-2" />
          返回上一页
        </el-button>
      </div>
    </div>
    
    <!-- 底部信息 -->
    <div class="error-footer">
      <p>© 2024 Your System Name. All rights reserved.</p>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { WarningFilled, HomeFilled, ArrowLeft } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'

const router = useRouter()

// 返回首页
const handleBackHome = () => {
  router.push('/').then(() => {
    ElMessage.success('已为您返回首页')
  })
}

// 返回上一页
const handleGoBack = () => {
  if (window.history.length > 1) {
    router.back()
  } else {
    router.push('/')
    ElMessage.info('已无历史记录，为您返回首页')
  }
}
</script>

<style scoped>
.error-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: #f5f7fa;
  overflow: hidden;
}

/* 背景装饰图案 */
.bg-pattern {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(64, 158, 255, 0.05) 0%, transparent 20%),
    radial-gradient(circle at 80% 70%, rgba(64, 158, 255, 0.05) 0%, transparent 20%);
  z-index: 1;
}

/* 主体内容容器 */
.error-container {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 40px 20px;
  border-radius: 16px;
  background-color: #fff;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.08);
  width: 90%;
  max-width: 600px;
  transition: transform 0.3s ease;
}

.error-container:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 60px rgba(0, 0, 0, 0.12);
}

/* 错误图标 */
.error-icon {
  color: #e6a23c;
  margin-bottom: 30px;
  position: relative;
  animation: float 3s ease-in-out infinite;
}

/* 错误代码与信息 */
.error-code {
  font-size: 64px;
  font-weight: 700;
  color: #1d2129;
  margin: 0 0 15px;
  letter-spacing: 8px;
}

.error-message {
  font-size: 20px;
  color: #4e5969;
  margin: 0 0 10px;
}

.error-description {
  font-size: 14px;
  color: #86909c;
  margin: 0 0 30px;
  line-height: 1.6;
}

/* 操作按钮 */
.error-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.back-home-btn {
  background-color: #409eff;
  border-color: #409eff;
  transition: all 0.3s ease;
}

.back-home-btn:hover {
  background-color: #66b1ff;
  transform: translateY(-2px);
}

.go-back-btn {
  background-color: #f5f7fa;
  color: #4e5969;
  transition: all 0.3s ease;
}

.go-back-btn:hover {
  background-color: #eef2f7;
  transform: translateY(-2px);
}

/* 底部信息 */
.error-footer {
  position: relative;
  z-index: 2;
  margin-top: 50px;
  color: #86909c;
  font-size: 12px;
  text-align: center;
}

/* 动画效果 */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* 响应式调整 */
@media (max-width: 768px) {
  .error-code {
    font-size: 48px;
  }
  
  .error-message {
    font-size: 18px;
  }
  
  .error-actions {
    flex-direction: column;
    width: 80%;
    margin: 20px auto 0;
  }
  
  .error-icon {
    margin-bottom: 20px;
  }
  
  .error-container {
    padding: 30px 15px;
  }
}
</style>